jQuery(document).ready(function () {
    var grid_selector = "#grid-table";
    var pager_selector = "#grid-pager";


    var op_func = function (p1, p2, record) {
        var op_edit = '<a href="/sys_organization/edit-sys_organization.html?id=' + record.id + '" title="编辑">编辑</a>';
        //  var op_delete = '<a href="#" title="删除" class="btn-op-delete" data-id="'+record.id+'" >删除</a>';

        return op_edit + "&nbsp;&nbsp;&nbsp;";
    }


    jQuery(grid_selector).jqGrid({
        url: "/sys_organization/list-sys_organization.ajax",
        datatype: "json",
        height: '100%',
        mtype: "GET",
        colNames: ['', '', '', '', '', '', '', '', '', '', '操作'],
        colModel: [
            {name: 'id', index: 'id', width: 150, hidden: true},
            {name: 'name', index: 'name', width: 150},
            {name: 'parentId', index: 'parentId', width: 150},
            {name: 'parentIds', index: 'parentIds', width: 150},
            {name: 'available', index: 'available', width: 150},
            {name: 'id', index: 'id', width: 150, hidden: true},
            {name: 'name', index: 'name', width: 150},
            {name: 'parentId', index: 'parentId', width: 150},
            {name: 'parentIds', index: 'parentIds', width: 150},
            {name: 'available', index: 'available', width: 150},
            {name: 'op', width: 150, formatter: op_func}
        ],
        viewrecords: true,
        rowNum: 20,
        rowList: [20, 50, 100],
        pager: pager_selector,
        altRows: true,
        multiselect: true,
        multiboxonly: true,
        loadComplete: function () {
            jqGrid.reset(jQuery);


        },
        autowidth: true
    });


    jQuery('#btn-query').click(function () {
        //var name = jQuery('#name').val();

        jQuery(grid_selector).jqGrid('setGridParam',
            {
                postData: {
                    // name: name,
                    xyz: 1
                }, page: 1
            }).trigger("reloadGrid");

    });


});